#include <stdio.h>

#define MAXLINE 1000

void reverse(char out[], char s[], int len);
int getline2(char line[], int maxline);

int main()
{
    char line[MAXLINE];
    char out[MAXLINE];
    int len;

    while ((len = getline2(line, MAXLINE)) > 0)
    {
        reverse(out, line, len);
        printf("out = %s\n", out);
    }

    return 0;
}

void reverse(char out[], char s[], int len)
{
    int i;

    i = 0;
    while ((out[i] = s[len - i - 1]) != '\0')
    {
        ++i;
    }
}

int getline2(char line[], int maxline)
{
    int c, i;

    for (i = 0; i < maxline - 1 && (c = getchar()) != EOF && c != '\n'; i++)
    {
        line[i] = c;
    }
    if (c == '\n')
    {
        line[i] = c;
        i++;
    }
    line[i] = '\0';
    return i;
}